<template>
  <div class="frame">
    <Header />
    <div class="center">
      <div class="left">
        <div class="writeblog">权限功能</div>
        <div>
          <el-row class="tac">
            <el-col :span="12">
              <el-menu
                default-active="2"
                class="el-menu-vertical-demo"
                @open="handleOpen"
                @close="handleClose"
              >
                <el-submenu index="1">
                  <template slot="title">
                    <i class="el-icon-location"></i>
                    <span>评选优秀博客</span>
                  </template>
                  <el-menu-item-group>
                    <template slot="title">评选优秀博客</template>
                    <el-menu-item index="1-1" @click="toExcellentBolgRule"
                      ><span>评选优秀博客规则</span></el-menu-item
                    >
                    <el-menu-item index="1-2" @click="toExcellentBolgChoose"
                      ><span>选择优秀博客</span></el-menu-item
                    >
                    <el-menu-item index="1-3" @click="toExcellentBolg"
                      ><span>优秀博客</span></el-menu-item
                    >
                  </el-menu-item-group>
                </el-submenu>
                <el-submenu index="2">
                  <template slot="title">
                    <i class="el-icon-setting"></i>
                    <span>评选博客之星</span>
                  </template>
                  <el-menu-item-group title="评选博客之星">
                    <el-menu-item index="2-1" @click="toStarBolgRule"
                      ><span>评选博客之星规则</span></el-menu-item
                    >
                    <el-menu-item index="2-2" @click="toStarBolgListChoose"
                      ><span>选择博客之星</span></el-menu-item
                    >
                    <el-menu-item index="2-3" @click="toStarBolgList"
                      ><span>博客之星</span></el-menu-item
                    >
                  </el-menu-item-group>
                </el-submenu>

                <el-submenu index="3">
                  <template slot="title">
                    <i class="el-icon-document"></i>
                    <span>内容审核</span>
                  </template>
                  <el-menu-item-group title="内容审核">
                    <el-menu-item index="3-1" @click="toBlogReview"
                      ><span>内容审核</span></el-menu-item
                    >
                  </el-menu-item-group>
                </el-submenu>
              </el-menu>
            </el-col>
          </el-row>
        </div>
      </div>
      <div class="right">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script>
// import $ from "jquery";
import Header from "../../components/Header.vue";
export default {
  name: "UserPermissions",
  data() {
    return {};
  },
  components: {
    Header,
  },
  methods: {
    // 优秀博客规则
    toExcellentBolgRule() {
      this.$router.push({
        name: "ExcellentBlogsRule",
      });
    },
    // 优秀博客
    toExcellentBolg() {
      this.$router.push({
        name: "ExcellentBlogsList",
      });
    },
    // 选择优秀博客
    toExcellentBolgChoose() {
      this.$router.push({
        name: "ExcellentBlogsListChoose",
      });
    },
    // 博客之星规则
    toStarBolgRule() {
      this.$router.push({
        name: "StarBlogsRule",
      });
    },
    // 博客之星
    toStarBolgList() {
      this.$router.push({
        name: "StarBlogsList",
      });
    },
    // 选择博客之星
    toStarBolgListChoose() {
      this.$router.push({
        name: "StarBlogsListChoose",
      });
    },
    // 博客审核
    toBlogReview() {
      this.$router.push({
        name: "UserBlogReview",
      });
    },

    // element方法
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },

    //页面加载
    pageLoad() {
      let userData = JSON.parse(sessionStorage.getItem("LoginMessage")).message;
      this.picture = "http://" + userData.picture;
    },
  },

  mounted() {
    // 获取当前用户分配的角色
    this.$http({
      method: "post",
      url: "user/showUserRole",
    }).then(({ data }) => {
      if (data.flag) {
        this.$message.success("欢迎来到管理页面");
        // 把角色存进vuex
        this.$store.commit("Role", {
          roles: data.data,
        });
      } else {
        this.$message.error("您当前没有任何权限");
        // 把角色存进vuex（没有角色则是空）
        this.$store.commit("Role", {
          roles: data.data,
        });
      }
    });
  },
};
</script>

<style lang="less" scoped>
.a {
  background-color: pink;
  color: skyblue;
}
.frame {
  background-color: #fafafa;
  min-height: 100%;
}
* {
  list-style: none;
}
a {
  text-decoration: none;
  color: black;
}
.center {
  width: 100%;
  // min-height: 700px;
  // background-color: #fafafa;
  padding: 20px;
  box-sizing: border-box;
  position: relative;
  // clear: both;
  // .left,
  // .right {
  //   // float: left;
  //   margin-top: 30px;
  // }
  .left {
    // background-color: pink;
    width: 280px;
    // position: fixed;
    margin-top: 30px;
    // height: 500px;
    margin-left: 20px;
    position: relative;
    top: 0;
    left: 0;
    // display: inline-block;
    float: left;
    vertical-align: top;
    .writeblog {
      width: 150px;
      // position: absolute;
      height: 50px;
      text-align: center;
      margin-left: 20px;
      background-color: #fff;
      border: 2px solid #ccc;
      line-height: 50px;
      margin-bottom: 20px;
      font-weight: 700;
      color: #6d6d6d;
      letter-spacing: 5px;
      border-radius: 25px;
      cursor: pointer;
      font-size: 20px;
      &:hover {
        background-color: #6d6d6d;
        color: #fff;
      }
    }
  }
  .right {
    background-color: #fff;
    // margin-left: 50px;
    width: 1100px;
    // display: inline-block;
    // height: 500px;
    // position: absolute;
    // right: 0;
    margin-top: 50px;
    // bottom: 0;
    margin-left: 300px;
    // overflow-y: auto;
    // margin-bottom: 50px;
  }
  .el-menu {
    width: 200px;
  }
}
</style>